package com.tgy.Filter;

import javax.servlet.*;
import java.io.IOException;

/***
 * @ClassName: FilterTest1
 * @Description: 测试过滤器
 * @Auther: 送一一块二向箔
 * @Date: 9:45 2021/12/9
 * @version : V1.0
 */
public class FilterTest1 implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("创建");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        servletRequest.setCharacterEncoding("utf-8");
        servletResponse.setContentType("text/html; charset=UTF-8");
        System.out.println("执行前");
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println("执行后");
    }

    @Override
    public void destroy() {
        System.out.println("销毁");
    }
}
